package Level02_seven;

import java.util.HashSet;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        HashSet<Object> hashSet = new HashSet<>();
        System.out.println("请输入一个数字");
        while (true) {
            int num = scanner.nextInt();
            if (num == -1) {
                break;
            } else {
                hashSet.add(num);
            }
        }
        //将hashSet中的元素相加
        int sum = 0;
        for (Object o : hashSet) {
            sum += (int) o;
        }
        System.out.println("不重复的数字相加为："+sum);
    }
}
